//
//  TravelTactic_MainCollectionViewCell.m
//  BTRIP
//
//  Created by Rain on 15/11/13.
//  Copyright © 2015年 johnbk. All rights reserved.
//

#import "TravelTactic_MainCollectionViewCell.h"
#import "TravelTactic_MainModel.h"
#import <UIImageView+WebCache.h>
#import <SDWebImageManager.h>

@implementation TravelTactic_MainCollectionViewCell

- (void)dealloc
{
    [_image_url release];
    [_name_en release];
    [_name_zh_cn release];
    [_poi_count release];
    [_travelTactic_MainModel release];
    
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame {
    
    self = [super initWithFrame:frame];
    if (self) {
        self.image_url = [[UIImageView alloc] init];
        self.image_url.layer.cornerRadius = 5 * SWIDTH;
        self.image_url.layer.masksToBounds = YES;
        [self.contentView addSubview:self.image_url];
        [self.image_url release];
        
        self.name_zh_cn = [[UILabel alloc] init];
        self.name_zh_cn.textColor = [UIColor whiteColor];
        self.name_zh_cn.shadowColor = [UIColor grayColor];
        self.name_zh_cn.font = [UIFont systemFontOfSize:20 weight:2];
        [self.contentView addSubview:self.name_zh_cn];
        [self.name_zh_cn release];
        
        self.name_en = [[UILabel alloc] init];
        self.name_en.textColor = [UIColor whiteColor];
        self.name_en.shadowColor = [UIColor grayColor];
        self.name_zh_cn.font = [UIFont systemFontOfSize:16 weight:2];
        [self.contentView addSubview:self.name_en];
        [self.name_en release];
        
        self.poi_count = [[UILabel alloc] init];
        self.poi_count.font = [UIFont systemFontOfSize:12];
        self.poi_count.textColor = [UIColor whiteColor];
        self.poi_count.textAlignment = NSTextAlignmentCenter;
        self.poi_count.layer.cornerRadius = 10 * SWIDTH;
        self.poi_count.layer.masksToBounds = YES;
        self.poi_count.backgroundColor = [UIColor colorWithRed:48/255 green:55/255 blue:64/255 alpha:0.8];
        [self.contentView addSubview:self.poi_count];
        [self.poi_count release];
        
    }
    return self;
}

- (void)layoutSubviews {
    
    [super layoutSubviews];
    
    self.image_url.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
    self.name_zh_cn.frame = CGRectMake(10 * SWIDTH, 10 * SWIDTH, 200 * SWIDTH, 30 * SWIDTH);
    self.name_en.frame = CGRectMake(10 * SWIDTH, 40 * SWIDTH, 200 * SWIDTH, 20 * SWIDTH);
    self.poi_count.frame = CGRectMake(self.frame.size.width - self.frame.size.width / 4 * 3, self.frame.size.height - 40 * SWIDTH, self.frame.size.width / 2, 20 * SWIDTH);
    
}

- (void)setTravelTactic_MainModel:(TravelTactic_MainModel *)travelTactic_MainModel {
    
    if (_travelTactic_MainModel != travelTactic_MainModel) {
        [_travelTactic_MainModel release];
        _travelTactic_MainModel = [travelTactic_MainModel retain];
    }
    
    [self.image_url sd_setImageWithURL:[NSURL URLWithString:_travelTactic_MainModel.image_url] placeholderImage:[UIImage imageNamed:@"background"]];
    self.name_zh_cn.text = _travelTactic_MainModel.name_zh_cn;
    self.name_en.text = _travelTactic_MainModel.name_en;
    self.poi_count.text = [NSString stringWithFormat:@"旅行地 %@", _travelTactic_MainModel.poi_count];
    
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
